package git.soulbgm.config;

import git.soulbgm.utils.JwtUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @author SoulBGM
 * @version 1.0
 * @date 2019/11/6 16:46
 */
@ConfigurationProperties(prefix = "config.token")
@PropertySource(value = "classpath:/config/config.properties")
@Configuration
@Data
public class TokenConfig {

    /**
     * Token过期时间，单位分钟
     */
    private int tokenExpireTime;

    /**
     * 刷新Token过期时间，单位分钟
     */
    private int refreshTokenExpireTime;

    /**
     * Token加密密钥
     */
    private String secretKey;

    /**
     * header的Token的名称
     */
    private String headerName;

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
        JwtUtil.setJwtRule(secretKey);
    }
}
